package cz.acies.genea.ui.svg;

import com.google.gson.JsonObject;

public class G2Text extends G2Point
{
	private static final long serialVersionUID = 6382107700762788048L;
	
	public static final int HORIZONTAL = 0; 
	public static final int VERTICAL = -90;
	
	protected String text;
	protected int angle = HORIZONTAL;
	
	protected int fontSise = 14;
	
	public G2Text() {
		this(0, 0, "");
	}

	public G2Text(double x, double y, String text) {
		this.x = x;
		this.y = y;
		this.text = text;
	}

	// -----  -----------------------------------------------------------------

	@Override
	public JsonObject toJSON(JsonObject element) {
		element = super.toJSON(element);
		JsonObject draw = (JsonObject) element.get("draw");
		draw.addProperty("text", ""+this.getText());
		draw.addProperty("x", this.x);
		draw.addProperty("y", this.y);
		//draw.addProperty("text-anchor", "start");
		draw.addProperty("text-anchor", "start");
		draw.addProperty("fill-opacity", 1);
		draw.addProperty("font-family", "Arial, Helvetica, sans-serif"); 
		draw.addProperty("font-size", fontSise);
		
		draw.remove("stroke");		
		draw.remove("fill"); 
		return element;
	}

	// -----  -----------------------------------------------------------------
	
	@Override
	public String getType() {
		return "text";
	}

	// -----  -----------------------------------------------------------------

	/**
	 * Vrac� hodnotu text.
	 *
	 * @return - vrac� hodnotu text
	 */
	public String getText() {
		return text;
	}

	/**
	 * Zad� hodnotu text.
	 *
	 * @param text nov� hodnota text
	 */
	public void setText(String text) {
		this.text = text;
	}

	// -----  -----------------------------------------------------------------
	
	/* (non-Javadoc)
	 * @see com.smart4web.wcad.geom.G2Point#toString()
	 */
	public String toString() {
		return "G2Text[x = " + this.x + ", y = " + this.y + ", text = " + this.text + "]"; 
	}

	public int getAngle() {
		return angle;
	}

	public void setAngle(int angle) {
		this.angle = angle;
	}

	public int getFontSise() {
		return fontSise;
	}

	public void setFontSise(int fontSise) {
		this.fontSise = fontSise;
	}

}
